﻿Imports System
Imports System.Collections
Imports System.Collections.Specialized
Imports System.Drawing

Namespace System.Workflow.ComponentModel.Design
    Public Class DesignerView
        ' Methods
        Public Sub New(ByVal viewId As Integer, ByVal [text] As String, ByVal image As Image)
            If ([text] Is Nothing) Then
                Throw New ArgumentNullException("text")
            End If
            If (image Is Nothing) Then
                Throw New ArgumentNullException("image")
            End If
            Me.viewId = viewId
            Me.text = If(([text].Length > DesignerView.MaxViewName), ([text].Substring(0, DesignerView.MaxViewName) & "..."), [text])
            Me.image = image
        End Sub

        Public Sub New(ByVal viewId As Integer, ByVal [text] As String, ByVal image As Image, ByVal associatedDesigner As ActivityDesigner)
            Me.New(viewId, [text], image)
            If (associatedDesigner Is Nothing) Then
                Throw New ArgumentNullException("associatedDesigner")
            End If
            Me.designer = associatedDesigner
        End Sub

        Public Overrides Function Equals(ByVal obj As Object) As Boolean
            Dim view As DesignerView = [TryCast](obj,DesignerView)
            If (view Is Nothing) Then
                Return False
            End If
            Return (Me.viewId = view.viewId)
        End Function

        Public Overrides Function GetHashCode() As Integer
            Return Me.viewId
        End Function

        Public Overridable Sub OnActivate()
        End Sub

        Public Overridable Sub OnDeactivate()
        End Sub


        ' Properties
        Public Overridable ReadOnly Property AssociatedDesigner As ActivityDesigner
            Get
                Return Me.designer
            End Get
        End Property

        Public ReadOnly Property Image As Image
            Get
                Return Me.image
            End Get
        End Property

        Public ReadOnly Property [Text] As String
            Get
                Return Me.text
            End Get
        End Property

        Public ReadOnly Property UserData As IDictionary
            Get
                If (Me.userData Is Nothing) Then
                    Me.userData = New HybridDictionary
                End If
                Return Me.userData
            End Get
        End Property

        Public ReadOnly Property ViewId As Integer
            Get
                Return Me.viewId
            End Get
        End Property


        ' Fields
        Private designer As ActivityDesigner
        Private image As Image
        Private Shared MaxViewName As Integer = 150
        Private [text] As String
        Private userData As IDictionary
        Private viewId As Integer
    End Class
End Namespace

